home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
A Field Trip to the Sky (Demo)
/
Mac_Sunburst_AFieldTripToTheSky-Demo.iso
/
DIR
/
SHARED.DIR
/
01102_Script_Button Handlers
< prev
next >
Wrap
Text File
|
1996-03-27
|
3KB
|
146 lines
global gGameFrame
-- ïïïï doInitGeneralButtons ïïïï
-- change the go back button and title if we're in a general screen like the Terms
on doInitGeneralButtons id
-- its a real object screen, it'll have all these things
if gGameFrame = 0 OR the moviename contains "game" then
setCastPicture id, "O", "BACKUP.PICT", 1164
setCastPicture id, "O", "BACKDN.PICT", 1163
end if
setCastPicture id, "", "title.pict", 1161
end
on setCastPicture id, prefix, castName, dstNum
duplicate cast (id & castName), dstNum
set the name of cast dstNum to castName
end
-- ïïï doUpdateSound ïïï
-- update the file that points to the basic structure so that we have the right sound
on doUpdateSound
global gVol, gPathChar
set theNewName to gVol & "DIR" & gPathChar & "BASIC"
if( the soundEnabled ) then
set theNewName to theNewName & "ON.DIR"
else
set theNewName to theNewName & "OFF.DIR"
end if
if theNewName <> the fileName of cast 1162 then
set the fileName of cast 1162 to theNewName
end if
updateStage
end
-- ïïïï doButtonPress ïïïï
-- change the button to a different cast to show its pressed
on doButtonPress
-- first get the number of the sprite we're dealing with
set theSprite to the clickOn
doStartModButtonPress( theSprite, (the castNum of sprite theSprite) - 1, 0 )
doEndButtonPress()
return TRUE
end doButtonPress
-- ïïïï doStartButtonPress ïïïï
-- start a timed button press
on doStartButtonPress
set theSprite to the clickOn
return doStartModButtonPress( theSprite,(the castNum of sprite theSprite) - 1, 20 )
end doStartButtonPress
-- ïïïï doStartModButtonPress ïïïï
-- change the button to a different cast to show its pressed
-- with timer/sprite modifiers
global gButtonSprite
global gUpCast
on doStartModButtonPress theSprite, downCast, downTime
-- first get the number of the sprite we're dealing with
set gButtonSprite to theSprite
set gUpCast to the castNum of sprite theSprite
-- puppet it
puppetSprite gButtonSprite, TRUE
-- do the click down sound
puppetSound "Mouse Down Sound"
-- change the sprite and redraw
set the castNum of sprite gButtonSprite to downCast
updateStage
-- return TRUE if the mouse is still over this sprite
-- startTimer()
--
-- first check if its a short click
-- repeat while the stillDown AND (downTime = 0 OR the timer < downTime)
-- nothing
-- end repeat
--
-- -- its a long click if we're still down
-- return the stillDown
return TRUE
end doStartModButtonPress
-- ïïïï doEndButtonPress ïïïï
-- change the button back to its original state
on doEndButtonPress
-- wait for a button up
-- repeat while the stillDown
-- nothing
-- end repeat
-- do the upclick
puppetSound "Mouse Up Sound"
-- change the button
set the castNum of sprite gButtonSprite to gUpCast
puppetSprite gButtonSprite, FALSE
updateStage
repeat while ( soundBusy(1) OR soundBusy(2) )
nothing
end repeat
puppetSound 0
updateStage
-- return TRUE if the mouse is still over this sprite
-- return rollover(gButtonSprite)
return TRUE
end doEndButtonPress